package net.wxxr.http.request;

import java.security.NoSuchAlgorithmException;

import net.wxxr.http.engine.HttpGetEngine;
import net.wxxr.http.util.CodeUtil;




public class HttpGetImageRequest extends HttpBaseRequest {
	public enum CornerType {
		CORNER_NORMAL(1), CORNER_ROUND(2);

		CornerType(int ni) {
			this.nativeInt = ni;
		}

		final int nativeInt;
	}

	public enum ResizeType {
		TIMELINE(1), WATERFALL(2), USERICON(3);

		ResizeType(int ni) {
			this.nativeInt = ni;
		}

		final int nativeInt;
	}

	/**
	 * 由图片URL经过MD5编码形成的ID
	 */
	private String imageID;

	/**
	 * 生产的图片是否有圆角
	 */
	private CornerType cornerType = CornerType.CORNER_NORMAL;

	/**
	 * 请求图片的宽度大小
	 */
	private int dstWidth;
	
	/**
	 * 请求图片的高度大小
	 */
	private int dstHeight;

	/**
	 * 当数量过多时自动移除任务
	 */
	private boolean autoRemove;

	public int getDstWidth() {
		return dstWidth;
	}

	public void setDstWidth(int dstWidth) {
		this.dstWidth = dstWidth;
	}

	public int getDstHeight() {
		return dstHeight;
	}

	public void setDstHeight(int dstHeight) {
		this.dstHeight = dstHeight;
	}

	public String getImageID() {
		return imageID;
	}

	/**
	 * 每次在Request设置完成后，需要调用一下generateImageID();
	 * @throws NoSuchAlgorithmException 
	 */
	public void generateImageID() throws NoSuchAlgorithmException {
		/**
		 * 设置完URL自动设置imageID
		 */
		this.imageID = CodeUtil.toMD5(getUrl());
	}

	public CornerType getCornerType() {
		return cornerType;
	}

	public void setCornerType(CornerType cornerType) {
		this.cornerType = cornerType;
	}

	public boolean isAutoRemove() {
		return autoRemove;
	}

	public void setAutoRemove(boolean autoRemove) {
		this.autoRemove = autoRemove;
	}
	
	@Override
	public void setUrl(String url) {
		// Auto-generated method stub
		super.setUrl(url);
	}

	@Override
	protected void initHttpEngine() {
		httpEngine = new HttpGetEngine(this);
	}

}
